package com.nuoniu.sibanyun.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.entity.SysUserRole;
import com.nuoniu.sibanyun.mapper.SysUserRoleMapper;
import com.nuoniu.sibanyun.service.ISysUserRoleService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户与角色关联表 服务实现类
 * </p>
 *
 * @author baiqiang
 * @since 2020-04-23
 */
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {

    @Autowired
    private SysUserRoleMapper userRoleMapper;

    @Override
    public List<Long> checkRoleId(Long userId) {
        UserInfo userInfo = UserThreadLocal.get();
        return userRoleMapper.checkRoleId(userId, userInfo.getCompanyId());
    }

    @Override
    public List<SysUserRole> getByRoleId(Long id) {
        return userRoleMapper.getByRoleId(id);
    }
}
